from django.db import models

class FlyUser(models.Model):

    userName = models.CharField(max_length=100, verbose_name='用户名')
    passWord = models.CharField(max_length=100, verbose_name='密码')
    addTime = models.DateTimeField(auto_now_add=True, verbose_name='添加时间')

    class Meta:
        db_table = 't_fly_user'
        verbose_name = '小说用户管理'
        verbose_name_plural = verbose_name
    # 添加该函数
    def __str__(self):
        return self.userName

class FlyConfig(models.Model):

    virtual_choice = (
            (1, '作品相关'),
            (2, '正文'),
            (-10, '回收站'),
            (-20, '草稿箱'),
        )
    bookName = models.CharField(max_length=200,verbose_name='书名')
    userName = models.ForeignKey(FlyUser, on_delete=models.CASCADE,verbose_name='账号')
    relessesUrl = models.CharField(max_length=300,verbose_name='发布地址')
    proxyHost = models.CharField(max_length=300,verbose_name='代理ip',default='127.0.0.1')
    proxyPort = models.CharField(max_length=300,verbose_name='代理port',default='80')
    proxyUser = models.CharField(max_length=300,verbose_name='代理name',default='')
    proxyPass = models.CharField(max_length=300,verbose_name='代理pwd',default='')
    pluginPath = models.CharField(max_length=300,verbose_name='代理插件路径',default='')
    wordPath = models.CharField(max_length=200,verbose_name='word文件路径')
    startPar = models.CharField(max_length=30,verbose_name='开始章节')
    endPar = models.CharField(max_length=30,verbose_name='结束章节')
    currentChapter = models.IntegerField(verbose_name='当前章节',default=1)
    selectFlag = models.IntegerField(verbose_name='分卷类型', choices=virtual_choice, default=-20)
    addTime = models.DateTimeField(auto_now_add=True, verbose_name='添加时间')

    class Meta:
        db_table = 't_fly_config'
        verbose_name = '网站配置'
        verbose_name_plural = verbose_name